﻿<!--#include file="h.asp"--><%
'
'	七色虎建站系统
'	文章页面
'	2012.4.5

Sub main
	'文章及评论配置
	If wapHits<>"1" And wapHits<>"0" Then wapHits="1"'文章显示点击率
	If Not ifNum(numArticle) Then numArticle="500"'文章每页字数
	If Not ifNum(numHit) Then numHit="0"'文章点击种子
	If Not ifNum(numDiscuss) Then numDiscuss="0"'文章评论最少字数
	If wapDiscuss<>"1" And wapDiscuss<>"0" Then wapDiscuss="0"'文章评论功能
	If Not ifNum(wapAccess) Then wapAccess="0"'会员独享
	
	
	Dim p,rs,sql,hit,author,tpl,ids,rss,title,savetime,id,userid,body_,title_,pretitle_,description_,classname
	Dim weibo,link_,content_,fileId,fileLink,rsFile,keep
	Dim Counts,Content,pageWordNum,StartWord,Length,PageAll,page,i,arr,pageShow,view,discuss,ad3txt,rndtxt,ad2txt,input
	userid=user_array(0)
	If userid=0 And (wapAccess="1" Or wapAccess="5") Then
		rupt "错误","文章仅会员独享,请"&hu.url("bbs_login.asp?_u="&back_url,"登录")&"查看"
	End If
	body_ = ""
	id=getN("id",1)
	tpl=ubbcode(tplArticle)
	p=getN("p",1)
	Set rs = hu.conn("select top 1 title,test,hit,smspin,classid,HU_author,HU_date,fileid from 74hu_article where id="&id)
	if rs.eof then
		rs.close
		set rs=Nothing
		rupt "错误","文章已删除!"
	end if
	ids=rs("classid")
	title=nowml(rs("title"))
	savetime=forDate(rs("HU_date"))
	author=rs("HU_author")
	fileId=rs("fileid")
	Call setVisitPage("<a href='"&http_path&"article.asp?id="&id&"&amp;[sid]'>"&getLeft(title,8)&"</a>")
	If userid>0 Then Call setUserAmount(userid, amtArt)'加金币积分经验
	fileLink =  ""
	If fileId>0 Then
		Set rsFile=hu.conn("select top 1 buy,filesize,filetype from 74hu_download where id="&fileId)
		If Not rsFile.eof Then
			fileLink = "<br/>"&showImg("file")&hu.url("download.asp?id="&fileId,"(格式"&rsFile("filetype")&"/大小"&_
				forFileSize(rsFile("filesize"))&"/"&rsFile("buy")&bbsMoney&")")
		End If
		rsFile.close
		Set rsFile=Nothing
	End If
	If IsNumeric(author) Then
		author= hu.url("bbs_user.asp?id="&author,noubb(getUserName(author)))
	Else
		author=nowml(author)
	End If
	Set rss = hu.conn("select top 1 class from 74hu_list where classid="&ids)
	if rss.eof then
		rss.close
		set rss=Nothing
		rupt "错误","文章已删除!"
	end if
	classname = rss("class")
	hit=1
	if numHit>0 then
		Randomize
		hit=Int(Rnd*numHit)+1
	end if
	hit=rs("hit")+hit
	hu.conn("update 74hu_article set hit="&hit&" where id="&id)
	If wapHits=0 Then hit = "100%"
	keep = showImg("keep")&hu.url("bbs_keep.asp?a=1&amp;classid=2&amp;id="&id, "收藏这篇文章")
	body_ = body_ & checkMsg()'信息
	body_ = body_ & comUbb("[div=nav]-" & hu.url("?aid=index","首页")&"-"& hu.url("list.asp?id="&ids&"&amp;page="&p, classname)&"-正文[/div]")
	Counts=rs("smspin")
	ad2txt=getAD(2,1)
	StartWord = 1
	Content=rs("test")
	page=getN("page",1)
	if page<1 then page=1
	view=getData("view")
	If view<>"all" Then
		view = "paging"
		pretitle_ = ""
		Length=len(Content)
		pageWordNum=numArticle
		i=int(page-1)
		PageAll=(Length+PageWordNum-1)\PageWordNum
		if isnull(i) or IsNumeric(i)=False then i=0
		if instr(content,"||")>0 then
			arr=split(content,"||")
			PageAll=ubound(arr)+1
			if i>PageAll-1 then i=PageAll-1
			content = arr(i)
		else
			if clng(i)>int(PageAll) then i=PageAll-1
			Content = mid(Content,StartWord+i*PageWordNum,PageWordNum)
		end if
		If PageAll>1 Then pageShow= hu.url("article.asp?id="&id&"&amp;view=all","[显示全文]")&"<br/>"
	Else
		pretitle_ = "全文:"
		Content=Replace(Content,"||","")
		Length=len(Content)
		pageWordNum=3000'内容太多,每页显示3000字
		PageAll=(Length+PageWordNum-1)\PageWordNum
		if page>PageAll then page=PageAll
		i=int(page-1)
		If Length>pageWordNum Then pageShow= comUbb("[span=tip]内容过多,每页显示"&pageWordNum&"字[/span]")
		Content = mid(Content,StartWord+i*PageWordNum,PageWordNum)
		pageShow= hu.url("article.asp?id="&id,"[分页显示]")&pageShow&"<br/>"
	End If
	content_ = left(content,200)'暂定200字
	description_ = noUbbCode(pretitle_ & left(content_,50)) & "..."
	weibo = Server.URLEncode(noUbbCode(left(content_, 140)))
	link_ = Server.URLEncode(http_path &"article.asp?id="&id)
	weibo = "<a href='http://v.t.sina.com.cn/share/share.php?url="&link_&"&amp;title="&weibo&"'>"&showImg("xlwb")&"</a> "&_
		"<a href='http://v.t.qq.com/share/share.php?url="&link_&"&amp;title="&weibo&"'>"&showImg("qqwb")&"</a> "&_
		"<a href='http://sns.z.qq.com/share?url="&link_&"&amp;web_url="&link_&"&amp;title="&weibo&"'>"&showImg("qqkj")&"</a>"
	content=pageShow & ubbcode(content)&"<br/>"& showPage("article.asp", "p:"&p&",id:"&id&",view:"&view, i+1, PageAll)&fileLink
	rs.close
	Set rs = hu.conn("select top 4 pl from 74hu_pl where smsid="&id&" order by id desc")
	If Not rs.eof Then
		For i=0 To 4
			If rs.eof Then Exit For
			discuss=discuss& (counts - i)&"楼."&discussUbb(getLeft(noad(rs("pl")),15))&"<br/>"
			rs.movenext
		Next
	End If
	discuss=discuss& hu.url("discuss.asp?id="&id&"&amp;p="&p,"网友评论("&Counts&")")
	If wapDiscuss=1 And userid=0 Then
		input = hu.url("bbs_login.asp?_u="&back_url,"登录评论文章")&"<br/>"
	Else
		Dim formarray(2)
		formarray(0) = http_path&"comment.asp||post||提交"
		formarray(1) = "input||pl$$$$20$$200||"
		formarray(2) = "hidden||id$$"&id&"||p$$"&p&"||"&bbsSid&"$$"&sid&"||<br/>"
		input = hu.getForm(formarray) &" (支持"&hu.url("bbs_reply.asp?a=-1","UBB")&")<br/>"
	End If
	Dim rs1,nexttxt,prevtxt
	set rs1=hu.conn("select top 1 id,test,title from 74hu_article where classid="&ids&" and id<"&id&" order by id desc")
	if Not rs1.eof then nexttxt= hu.url("article.asp?id="&rs1("id")&"&amp;p="&p,"&gt;&gt;"&nowml(rs1("title")))&"<br/>"
	rs1.close
	set rs1=hu.conn("select top 1 id,test,title from 74hu_article where classid="&ids&" and id>"&id&" order by id asc")
	if Not rs1.eof then prevtxt= hu.url("article.asp?id="&rs1("id")&"&amp;p="&p,"&lt;&lt;"&nowml(rs1("title")))&"<br/>"
	rs1.close
	set rs1=nothing
	rndtxt=wendtitle(3,ids)
	ad3txt=getAD(3,1)
	rs.close
	set rs=nothing
	rss.close
	set rss=nothing
	Dim rndnum
	rndnum=time_r'要避免内容中有{}标签,需将{}转义
	tpl=Replace(tpl,"{","{_74hu_"&rndnum)
	tpl=Replace(tpl,"{_74hu_"&rndnum&"time}",savetime,1,1)
	tpl=Replace(tpl,"{_74hu_"&rndnum&"hit}",hit,1,1)
	tpl=Replace(tpl,"{_74hu_"&rndnum&"source}",author,1,1)
	tpl=Replace(tpl,"{_74hu_"&rndnum&"next}",nexttxt,1,1)
	tpl=Replace(tpl,"{_74hu_"&rndnum&"ad2}",ad2txt,1,1)
	tpl=Replace(tpl,"{_74hu_"&rndnum&"ad3}",ad3txt,1,1)
	tpl=Replace(tpl,"{_74hu_"&rndnum&"title}",title,1,1)
	tpl=Replace(tpl,"{_74hu_"&rndnum&"prev}",prevtxt,1,1)
	tpl=Replace(tpl,"{_74hu_"&rndnum&"rnd}",rndtxt,1,1)
	tpl=Replace(tpl,"{_74hu_"&rndnum&"input}",input,1,1)
	tpl=Replace(tpl,"{_74hu_"&rndnum&"content}",content,1,1)
	tpl=Replace(tpl,"{_74hu_"&rndnum&"discuss}",discuss,1,1)
	tpl=Replace(tpl,"{_74hu_"&rndnum&"weibo}",weibo,1,1)
	tpl=Replace(tpl,"{_74hu_"&rndnum&"keep}",keep,1,1)
	tpl=Replace(tpl,"<br/><br/>","<br/>")
	hu.title = pretitle_ & title &"(" & page& ")" & "-" &classname
	hu.description = description_
	hu.body = body_ & tpl
End Sub

%>